# Auther：wujehy
# email:wujehy@qq.com
# @File : forms.py
# @Time : 19-6-20 上午5:59

from django import forms
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm

from .models import *
class getDataAtoBForm(forms.Form):
    # Dregister_SET=set()
    # Dregister =

    panid=forms.CharField(max_length=32)
    f=forms.IntegerField(min_value=0,label="Form")
    t=forms.IntegerField(min_value=0,label="To")


class RegisterForm(UserCreationForm):
    class Meta(UserCreationForm.Meta):
        model = GeeJoansUser
        fields = ("username","email")


class LoginForm(forms.Form):
    username = forms.CharField(max_length=32)
    password = forms.CharField(max_length=64)

class createProjectForm(forms.Form):
    # openid=forms.CharField(max_length=32)
    title=forms.CharField(max_length=64)
    description=forms.CharField(max_length=128)
    note=forms.CharField(max_length=1024)
    type=forms.CharField(max_length=10,widget=forms.Select(choices=ProjectType.objects.all().values_list("name","name")))

class delProjectForm(forms.Form):
    project=forms.CharField(max_length=32)

class addDeviceForm(forms.Form):
    SENSOR='sensor'
    RELAY='relay'
    OTHER='other'
    Dtype_CHOICES=[(SENSOR,"传感器"),(RELAY,"执行器"),(OTHER,"其他")]
    pid=forms.IntegerField()
    Dtype=forms.CharField(max_length=16,widget=forms.Select(choices=Dtype_CHOICES))
    # Dregister=forms.CharField(max_length=32)


class delDevicesForm(forms.Form):
    device = forms.CharField(max_length=32,widget=forms.Select(choices=Devices.objects.filter(Pid=0).values_list("Dregister","Dregister")))

class uploadDataForm(forms.Form):
    data=forms.CharField(max_length=1024)
    # panid=forms.CharField(max_length=32)
    save=forms.BooleanField(required=False)

class controlDataForm(forms.Form):
    # panid=forms.CharField(max_length=32)
    data=forms.CharField(max_length=1024)
